// 根据角色动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";

export default defineFakeRoute([
  {
    url: "/get_pfmea_data",
    method: "get",
    response: ({ body }) => {
      if (body.value == "OP1010") {
        return {
          success: true,
          data: {
            username: "admin",
            roles: ["admin"]
          }
        };
      } else {
        return {
          success: true,
          data: [
            {
              ProcessFunction: "缸体上线load block",
              PotentialFailureMode:
                "吊装时损坏缸体总成外表面hit block when put block to workingplace",
              PotentialEffectsOfFailure: "损坏缸体Damage block(6)",
              Severity: "6",
              Class: "",
              PotentialCausesOfFailure:
                "未按标准化操作Not go as standardized operation",
              Occurence: "3",
              CurrentProcessControlsPrevention: "",
              CurrentProcessControlsDetection: "目视检查visual check(7)",
              Detection: "7",
              Rpn: "126",
              SeverZone: "3",
              DetectZone: "2",
              RiskPriorLevel: "3",
              RecommendedActions: "",
              ResponsibilityAndTargetCompletionDate: "",
              ActionTaken: "",
              ActionTakenSeverity: "",
              ActionTakenOccurence: "",
              ActionTakenDetection: "",
              ActionTakenRpn: ""
            },
            {
              ProcessFunction: "缸体上线load block",
              PotentialFailureMode:
                "吊装时损坏缸体总成外表面hit block when put block to workingplace",
              PotentialEffectsOfFailure: "损坏缸体Damage block(6)",
              Severity: "6",
              Class: "",
              PotentialCausesOfFailure:
                "未按标准化操作Not go as standardized operation",
              Occurence: "3",
              CurrentProcessControlsPrevention: "",
              CurrentProcessControlsDetection: "目视检查visual check(7)",
              Detection: "7",
              Rpn: "126",
              SeverZone: "3",
              DetectZone: "2",
              RiskPriorLevel: "3",
              RecommendedActions: "",
              ResponsibilityAndTargetCompletionDate: "",
              ActionTaken: "",
              ActionTakenSeverity: "",
              ActionTakenOccurence: "",
              ActionTakenDetection: "",
              ActionTakenRpn: ""
            },
            {
              ProcessFunction: "缸体上线load block",
              PotentialFailureMode:
                "吊装时损坏缸体总成外表面hit block when put block to workingplace",
              PotentialEffectsOfFailure: "损坏缸体Damage block(6)",
              Severity: "6",
              Class: "",
              PotentialCausesOfFailure:
                "未按标准化操作Not go as standardized operation",
              Occurence: "3",
              CurrentProcessControlsPrevention: "",
              CurrentProcessControlsDetection: "目视检查visual check(7)",
              Detection: "7",
              Rpn: "126",
              SeverZone: "3",
              DetectZone: "2",
              RiskPriorLevel: "3",
              RecommendedActions: "",
              ResponsibilityAndTargetCompletionDate: "",
              ActionTaken: "",
              ActionTakenSeverity: "",
              ActionTakenOccurence: "",
              ActionTakenDetection: "",
              ActionTakenRpn: ""
            }
          ]
        };
      }
    }
  },
  {
    url: "/get_pfmea_data2",
    method: "get",
    response: ({ body }) => {
      return {
        success: true,
        data: {
          username: "admin2",
          roles: ["admin2"]
        }
      };
    }
  }
]);
